package com.hra.logger.utils;

import android.annotation.SuppressLint;

public final class Utils {
    public static final boolean DEBUG = false;

    @SuppressLint("SdCardPath")
    public static final String LOG_PATH = "/sdcard/Logger";

    /**
     * Directory structure control variables
     * true: new dir structure: /sdcard/Logger/typeName/Log_timestamp/displayName_timestamp_index.log
     * false: old dir structure: /sdcard/Logger/Log_timestamp/typeName/displayName_timestamp_index.log
     */
    public static final boolean NEW_DIR_STRUCTURE = true;
    public static final long MAX_TOTAL_LOG_SIZE = 5 * 1024 * 1024L * 1024L;
    public static final long MAX_FILE_SIZE = 30 * 1024L * 1024L;
    public static final boolean USE_OLD_DIR_AFTER_REBOOT = false;
    public static final boolean FIRST_BOOT_COMPLETE_AUTO_START = false;

    public static final String ACTION_START_LOGGING = "ACTION_START_LOGGING";
    public static final String PRE_STATE_NAME = "Logger_LogState";
    public static final String KEY_LOG_TYPE = "log_type";
    public static final String KEY_BEGIN_RECORDING_TIME = "begin_recording_time";
    public static final String KEY_LAST_RECORD_TIME = "last_record_time";

    public static final int LOG_TYPE_KERNEL = 1;
    public static final int LOG_TYPE_MAIN = 1 << 1;
    public static final int LOG_TYPE_SYSTEM = 1 << 2;
    public static final int LOG_TYPE_CRASH = 1 << 3;
    public static final int LOG_TYPE_RADIO = 1 << 4;
    public static final int LOG_TYPE_EVENTS = 1 << 5;

    public static final String LOG_TYPE_NAME_KERNEL = "KernelLog";
    public static final String LOG_TYPE_NAME_MAIN = "MainLog";
    public static final String LOG_TYPE_NAME_SYSTEM = "SystemLog";
    public static final String LOG_TYPE_NAME_CRASH = "CrashLog";
    public static final String LOG_TYPE_NAME_RADIO = "RadioLog";
    public static final String LOG_TYPE_NAME_EVENTS = "EventsLog";

    public static final int[] LOG_TYPES = {
            LOG_TYPE_KERNEL,
            LOG_TYPE_MAIN,
            LOG_TYPE_SYSTEM,
            LOG_TYPE_CRASH,
            LOG_TYPE_RADIO,
            LOG_TYPE_EVENTS
    };

    // Obtain name based on log type
    public static String getLogTypeName(int logType) {
        switch (logType) {
            case LOG_TYPE_KERNEL:
                return LOG_TYPE_NAME_KERNEL;
            case LOG_TYPE_MAIN:
                return LOG_TYPE_NAME_MAIN;
            case LOG_TYPE_SYSTEM:
                return LOG_TYPE_NAME_SYSTEM;
            case LOG_TYPE_CRASH:
                return LOG_TYPE_NAME_CRASH;
            case LOG_TYPE_RADIO:
                return LOG_TYPE_NAME_RADIO;
            case LOG_TYPE_EVENTS:
                return LOG_TYPE_NAME_EVENTS;
            default:
                return "UnknownLogType";
        }
    }
}
